﻿using System;
using System.Collections.Generic;

namespace DCT.AutoUpdate.Code.Config
{
    /// <summary>
    /// 配置解析器
    /// </summary>
    public interface IConfigParser
    {
        /// <summary>
        /// 加载配置内容
        /// </summary>
        /// <param name="config"></param>
        IConfigParser Load(object config);

        /// <summary>
        /// 清除配置内容
        /// </summary>
        IConfigParser Clear();

        /// <summary>
        /// 把对象转化为配置内容
        /// </summary>
        /// <returns></returns>
        string ParseToString();

        /// <summary>
        /// 获取KV对象
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        IEnumerable<KeyValuePair<string, string>> GetKV(string key);

        /// <summary>
        /// 获取KV队列
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        IEnumerable<IEnumerable<KeyValuePair<string, string>>> GetListKV(string key);

        /// <summary>
        /// 获取字符串队列
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        IEnumerable<string> GetListVal(string key);

        /// <summary>
        /// 获取字符串
        /// </summary>
        /// <param name="key"></param>
        /// <param name="defaultVal"></param>
        /// <returns></returns>
        string GetVal(string key, string defaultVal);

        /// <summary>
        /// 设置KV对象
        /// </summary>
        /// <param name="key"></param>
        /// <param name="kv"></param>
        void SetKV(string key, IEnumerable<KeyValuePair<string, string>> kv);

        /// <summary>
        /// 设置KV队列
        /// </summary>
        /// <param name="key"></param>
        /// <param name="kvList"></param>
        void SetListKV(string key, IEnumerable<IEnumerable<KeyValuePair<string, string>>> kvList);

        /// <summary>
        /// 设置字符串队列
        /// </summary>
        /// <param name="key"></param>
        /// <param name="listVal"></param>
        void SetListVal(string key, IEnumerable<string> listVal);

        /// <summary>
        /// 设置字符串
        /// </summary>
        /// <param name="key"></param>
        /// <param name="val"></param>
        void SetVal(string key, string val);
    }
}
